import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '文章标题',
    align:"center",
    dataIndex: 'title'
   },
   {
    title: '文章摘要',
    align:"center",
    dataIndex: 'excerpt'
   },
   {
    title: '文章内容(Markdown格式)',
    align:"center",
    dataIndex: 'content'
   },
   {
    title: '分类ID',
    align:"center",
    dataIndex: 'categoryId'
   },
   {
    title: '分类名称',
    align:"center",
    dataIndex: 'categoryName'
   },
   {
    title: '文章图标',
    align:"center",
    dataIndex: 'icon'
   },
   {
    title: '文章颜色',
    align:"center",
    dataIndex: 'color'
   },
   {
    title: '文章标签(JSON数组)',
    align:"center",
    dataIndex: 'tags'
   },
   {
    title: '阅读次数',
    align:"center",
    dataIndex: 'readCount'
   },
   {
    title: '状态(0:草稿,1:发布,2:下架)',
    align:"center",
    dataIndex: 'status'
   },
   {
    title: '排序权重',
    align:"center",
    dataIndex: 'sortOrder'
   },
   {
    title: 'SEO关键词',
    align:"center",
    dataIndex: 'seoKeywords'
   },
   {
    title: 'SEO描述',
    align:"center",
    dataIndex: 'seoDescription'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createdBy'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createdTime'
   },
   {
    title: '更新人',
    align:"center",
    dataIndex: 'updatedBy'
   },
   {
    title: '更新时间',
    align:"center",
    dataIndex: 'updatedTime'
   },
   {
    title: '是否删除(0:否,1:是)',
    align:"center",
    dataIndex: 'deleted'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '文章标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入文章标题!'},
          ];
     },
  },
  {
    label: '文章摘要',
    field: 'excerpt',
    component: 'InputTextArea',
  },
  {
    label: '文章内容(Markdown格式)',
    field: 'content',
    component: 'InputTextArea',
  },
  {
    label: '分类ID',
    field: 'categoryId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入分类ID!'},
          ];
     },
  },
  {
    label: '分类名称',
    field: 'categoryName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入分类名称!'},
          ];
     },
  },
  {
    label: '文章图标',
    field: 'icon',
    component: 'Input',
  },
  {
    label: '文章颜色',
    field: 'color',
    component: 'Input',
  },
  {
    label: '文章标签(JSON数组)',
    field: 'tags',
    component: 'Input',
  },
  {
    label: '阅读次数',
    field: 'readCount',
    component: 'InputNumber',
  },
  {
    label: '状态(0:草稿,1:发布,2:下架)',
    field: 'status',
    component: 'InputNumber',
  },
  {
    label: '排序权重',
    field: 'sortOrder',
    component: 'InputNumber',
  },
  {
    label: 'SEO关键词',
    field: 'seoKeywords',
    component: 'Input',
  },
  {
    label: 'SEO描述',
    field: 'seoDescription',
    component: 'Input',
  },
  {
    label: '创建人',
    field: 'createdBy',
    component: 'Input',
  },
  {
    label: '创建时间',
    field: 'createdTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '更新人',
    field: 'updatedBy',
    component: 'Input',
  },
  {
    label: '更新时间',
    field: 'updatedTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '是否删除(0:否,1:是)',
    field: 'deleted',
    component: 'InputNumber',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  title: {title: '文章标题',order: 0,view: 'text', type: 'string',},
  excerpt: {title: '文章摘要',order: 1,view: 'textarea', type: 'string',},
  content: {title: '文章内容(Markdown格式)',order: 2,view: 'textarea', type: 'string',},
  categoryId: {title: '分类ID',order: 3,view: 'number', type: 'number',},
  categoryName: {title: '分类名称',order: 4,view: 'text', type: 'string',},
  icon: {title: '文章图标',order: 5,view: 'text', type: 'string',},
  color: {title: '文章颜色',order: 6,view: 'text', type: 'string',},
  tags: {title: '文章标签(JSON数组)',order: 7,view: 'text', type: 'string',},
  readCount: {title: '阅读次数',order: 8,view: 'number', type: 'number',},
  status: {title: '状态(0:草稿,1:发布,2:下架)',order: 9,view: 'number', type: 'number',},
  sortOrder: {title: '排序权重',order: 10,view: 'number', type: 'number',},
  seoKeywords: {title: 'SEO关键词',order: 11,view: 'text', type: 'string',},
  seoDescription: {title: 'SEO描述',order: 12,view: 'text', type: 'string',},
  createdBy: {title: '创建人',order: 13,view: 'text', type: 'string',},
  createdTime: {title: '创建时间',order: 14,view: 'datetime', type: 'string',},
  updatedBy: {title: '更新人',order: 15,view: 'text', type: 'string',},
  updatedTime: {title: '更新时间',order: 16,view: 'datetime', type: 'string',},
  deleted: {title: '是否删除(0:否,1:是)',order: 17,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}